package com.ivi.car.module.home.view.activity;

import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.ivi.car.R;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
 * Copyright
 * author zhengcheng
 * date 2018/3/15
 * describe
 * history
 */
@RunWith(AndroidJUnit4.class)
public class HomeActivityTest {

    @Rule
    public ActivityTestRule activityTestRule = new ActivityTestRule(HomeActivity.class);
    @Test
    public void onHomeActivityTest() throws Exception {
        //通过id找到button，执行点击事件跳转到
        Espresso.onView(withId(R.id.maintainCar)).perform(click());
        //点击返回按钮回到HomeActivity
        Espresso.pressBack();
        //通过文本"美容"找到view，并检查是否显示，然后执行点击事件
        Espresso.onView(withText("美容")).check(matches(isDisplayed())).perform(click());
        Espresso.pressBack();
        Espresso.onView(withText("预约保养")).check(matches(isDisplayed())).perform(click());
        Espresso.pressBack();
        Espresso.onView(withText("洗车")).check(matches(isDisplayed())).perform(click());
        Espresso.pressBack();
        Espresso.onView(withText("车辆维修")).check(matches(isDisplayed())).perform(click());
        Espresso.pressBack();
        Espresso.onView(withId(R.id.home_car_status_rv)).perform(click());
    }

}